/**
 * 1. 两数之和
 * @param nums 数组
 * @param target 目标值
 */
function twoSum(nums: number[], target: number): number[] {
  let map = new Map<number, number>()
  for (let i = 0; i < nums.length; i++) {
    let temp = target - nums[i]
    if (map.has(temp)) {
      return [map.get(temp) as number, i]
    } else {
      map.set(nums[i], i)
    }
  }
  return []
}